﻿@model IEnumerable<tantrinh.Models.SanPham>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@if (Request.IsAuthenticated && @Session["UserId"] != null)
{
    <h1>
        Quản lý sản phẩm</h1>
    <h2>
        Index</h2>

    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table>
        <tr>
            <th>
                MaSanPham
            </th>
            <th>
                TenSanPham
            </th>
            <th>
                GiaSanPham
            </th>
            <th>
                AnhDaiDien
            </th>
            <th>
                MoTa
            </th>
            <th>
                LuotView
            </th>
            <th>
                ChiTietDanhMuc
            </th>
            <th>
                NhanHieu
            </th>
            <th>
                NgayDang
            </th>
            <th>
                TinhTrang
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.MaSanPham)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TenSanPham)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.GiaSanPham)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.AnhDaiDien)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MoTa)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LuotView)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ChiTietDanhMuc.TenChiTietDanhMuc)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NhanHieu.TenNhanHieu)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NgayDang)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TinhTrang)
                </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id = item.SanPhamID }) |
                    @Html.ActionLink("Details", "Details", new { id = item.SanPhamID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.SanPhamID })
                </td>
            </tr>
        }
    </table>
}
else
{
    <p>
        Xin vui lòng đăng nhập</p>
    <script type="text/javascript">
        window.location.href = "http://localhost:3084/admin"
    </script>
}